﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace ITM495.OOExamples.Core
{
    public class HelpController: IController
    {
        public void Run(Options options)
        {
            DisplayHelp();
        }

        /// <summary>
        /// This method displays the top level help text for the example runner
        /// </summary>
        private static void DisplayHelp()
        {
            Console.WriteLine("ITM 495 Example Program");
            Console.WriteLine("\tUsage: ITM495.OOExamples.exe [Controller] [options]\n");

            Console.WriteLine("Command Line Options:\n");
            Console.WriteLine(".exe [Runner] [options]");

            Console.WriteLine("\t -?\t Display this help message\t\t");
            Console.WriteLine("\t -l\t Sets the logger: -l File");

            Console.WriteLine("\nAvailable Controllers:");

            //
            // We're using a little bit of reflection here again to 
            // peek into the current assembly and pull out all the types
            // that implment IController
            //
            var controllerType = typeof (IController);
            var types = Assembly.GetExecutingAssembly().GetTypes()
                .Where(p => controllerType.IsAssignableFrom(p) && p != controllerType)
                .OrderBy(p => p.Name);

            foreach(var t in types)
            {
                Console.WriteLine("\t-{0}\t", t.Name.Replace("Controller", ""));
            }

            Console.WriteLine("\nExamples:\n");
            Console.WriteLine("\tITM495.OOExamples.exe Shape -c 3");

        }

      
    }
}